#include "Factory.h"

using namespace Game;
using namespace Math;

Factory* Factory::_instance=NULL;

//Real world units to game units
float Factory::_meter=1.6666666f;
//Real ball diameter: 6cm
float Factory::_ballRadius=0.028f;
//Real table size: 124cm x 248cm (aprox. size 8)
Size Factory::_tableSize(1.1f,2.2f);

Factory::Factory()
{
}

Factory* Factory::instance()
{
	if (!_instance)
		_instance=new Factory();

	return _instance;
}

/**********
* GETTERS *
**********/

float Factory::ballRadius()
{
	return _ballRadius;
}

float Factory::meter()
{
	return _meter;
}

Size& Factory::tableSize()
{
	return _tableSize;
}

/*********
* CREATE *
*********/

Ball* Factory::createBall(int num)
{
	Ball* b=new Ball(num);
	b->setRadius(_ballRadius);
	b->setRotation(Quaternion(130.0f,Vector::X));
	Graphics::Texture* t=new Graphics::Texture("resources/textures/balls/"+getString<int>(num)+".jpg");
	b->setTexture(t);

	return b;
}

PoolTable* Factory::createPoolTable()
{
	PoolTable* p=new PoolTable(_tableSize);
	Graphics::Texture* t=new Graphics::Texture("resources/textures/cloth.green.jpg");
	p->setTexture(t);

	return p;
}
